package com.situ.mall.thread.consumer;

import java.util.Random;

public class ProducerThread extends Thread{
    private Panzi panzi;

    public ProducerThread(String name, Panzi panzi) {
        super(name);
        this.panzi = panzi;
    }

    public void run() {
        for (int i = 1; i <= 1000; i++) {
            Cake cake = new Cake("no: " + i);
            System.out.println(Thread.currentThread().getName() + " putCake: " + cake);
            panzi.putCake(cake);
            try {
                Thread.sleep(new Random().nextInt(5000));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }



}
